package pages;


import core.TestBase;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import utils.Log4Test;

public class HomePage extends TestBase {

    private String URL = "http://rozetka.com.ua/";

    protected By searchString = By.className("header-search-input-text");
    protected By notebookLink = By.xpath("//*[@id='head_banner_container']/div[4]/div[1]/div/div[3]/div[1]/div/ul/li[1]/a");
    protected WebElement notebookElement;

    public void open()
    {

        webDriver.get(URL);
        Log4Test.info("Open WebUrl " + URL);

    }

    public boolean isOpened()
    {
        return webDriver.getCurrentUrl().equals(URL);
    }

    public void searchProduct(String productName)
    {
        Log4Test.info("Search product " + productName);
        webDriver.findElement(searchString).clear();
        webDriver.findElement(searchString).sendKeys(Keys.RETURN);
        webDriver.findElement(searchString).click();
    }

    public void openLaptop (){
        Log4Test.info("Open notebook page");
        notebookElement = webDriver.findElement(notebookLink);
        notebookElement.click();



    }
}
